package com.ctshk.common.model;

import com.ctshk.common.enums.ChannelMainData;
import io.swagger.models.auth.In;
import lombok.Data;


/**
 * @author 谢诗宏
 * @description BaseEntity
 * @date 2020/12/15
 */
@Data
public class AppReq extends BaseReq {

    /**
     * 渠道编码,枚举ChannelMainData的code
     */
    private Long channelId;
    /**
     * 订单来源,枚举OrderSource的code
     */
    private Integer orderSource;
    /**
     * 公司类型,枚举CompanyType的code
     */
    private String companyType;

    /**
     * 清空属性值再赋值
     *
     * @param channel
     * @param os
     * @param ct
     */
    public void setProperties(String channel, String os, String ct) {
        this.setChannelId(null);
        this.setOrderSource(null);
        this.setCompanyType(null);

        if (channel != null) {
            Long channelCode = ChannelMainData.getIdByCode(channel);
            this.setChannelId(channelCode);
        }
        if (os != null) {
            this.setOrderSource(Integer.valueOf(os));
        }
        this.setCompanyType(ct);
    }
}
